fix: add setters to CJS compatibility layer in Settings#7481
fix: add setters to CJS compatibility layer in Settings#7481JohnMcLear merged 1 commit intodevelopfrom
Conversation
The CJS compatibility block added in fd97532 only defined getters, making settings properties read-only for plugins using require(). Plugins like ep_webrtc need to mutate settings (e.g. requireAuthentication) in tests. Add setters so CJS consumers can write properties too. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Review Summary by QodoAdd setters to CJS compatibility layer in Settings
WalkthroughsDescription• Add setters to CJS compatibility layer in Settings module • Enables CJS consumers to mutate settings properties • Fixes TypeError when plugins write to settings • Allows ep_webrtc and similar plugins to modify settings in tests Diagramflowchart LR
A["CJS Consumer"] -->|"read/write settings"| B["Settings Module"]
B -->|"defineProperty with getter+setter"| C["module.exports"]
C -->|"access settings"| D["Internal settings object"]
File Changes1. src/node/utils/Settings.ts
|
Code Review by Qodo
1. No regression test for setter
|
| if (!(key in currentExports)) { | ||
| Object.defineProperty(currentExports, key, { | ||
| get: () => (settings as any)[key], | ||
| set: (v: any) => { (settings as any)[key] = v; }, | ||
| enumerable: true, | ||
| configurable: true, | ||
| }); |
There was a problem hiding this comment.
1. No regression test for setter 📘 Rule violation ☼ Reliability
This bug fix changes module.exports property descriptors to add a setter, but the PR does not include any accompanying regression test to ensure CJS consumers can mutate settings. Without an automated test, the issue can silently reoccur if this change is reverted or refactored.
Agent Prompt
## Issue description
A bug fix was made to allow CJS consumers to mutate settings (by adding a `set` handler in the `module.exports` compatibility block), but no regression test was added.
## Issue Context
Without a test, a future refactor (or revert) could reintroduce `TypeError: Cannot set property which has only a getter` for CJS consumers.
## Fix Focus Areas
- src/node/utils/Settings.ts[670-676]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
Addressed in the latest push. Thanks for catching this!
Summary
module.exports, making settings read-only for CJS consumers.settings.requireAuthentication = false), which throwsTypeError: Cannot set property which has only a getter.setto the property descriptors so CJS consumers can both read and write settings.Test plan
🤖 Generated with Claude Code